package com.wlc.base.structure;

import java.util.Scanner;

/**
 * @author 王立朝 wanglichao@champion-credit.com
 * @description 选择结构
 * @date 2021-06-21 14:02
 */
public class Structure {

    /**
     * 顺序结构
     */
    public void method1() {
        System.out.println("请输入内容：");
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        if ("hello".equals(s)) {
            System.out.println("输入的是: " + s);
        }
        System.out.println("end");
    }

    /**
     * 多选择结构
     */
    public void method2() {
        System.out.println("请输入内容：");
        Scanner scanner = new Scanner(System.in);
        int score = scanner.nextInt();
        if (score > 60) {
            System.out.println("及格");
        } else {
            System.out.println("不及格");
        }
    }

    /**
     * 成绩分数大于60就是及格；小于60分就是不及格；
     */
    public void method3() {
        System.out.println("请输入成绩：");
        Scanner scanner = new Scanner(System.in);
        int score = scanner.nextInt();
        if (score == 100) {
            System.out.println("恭喜满分！");
        }else if(score<=100 && score>90){
            System.out.println("A");
        }else if(score<=90 && score>80){
            System.out.println("A");
        }else if(score<=80 && score>70){
            System.out.println("A");
        }else if(score<=70 && score>60){
            System.out.println("A");
        }else if(score<=60 && score>=0){
            System.out.println("不及格");
        }else{
            System.out.println("成绩不合法");
        }
    }

    /**
     * switch 选择结构
     * 支持：int,char,short,byte,jdk1.7 以后支持字符串
     */
    public void method4(){
        char grade = 'a';
        switch (grade) {
            case 'a':
                System.out.println("优秀");
                break;
            case 'b':
                System.out.println("良好");
                break;
            case 'c':
                System.out.println("及格");
                // break 表示停止，不会穿透，否则下面的也会执行
                break;
            case 'd':
                System.out.println("不及格");
                break;
            default:
                System.out.println("未知类型！");
        }
    }
    public void method5(){
        String name = "王立朝";
        switch (name) {
            case "王立朝":
                System.out.println("优秀");
                break;
            case "wanglichao":
                System.out.println("良好");
                break;
            default:
                System.out.println("未知类型！");
        }
    }

    public static void main(String[] args) {
        Structure structure = new Structure();
        structure.method5();
    }
}
